#!/bin/bash

N_ROW=4700
N_COL=1250
N_BYTES=2
FAST_MODE=0
FOUT_FNAME=tmp.bin


DAISY_CONFIG=`cat WKDIR`/daisy.ini

echo "*************************************************"
echo "> N_ROW       = ${N_ROW}"
echo "> N_COL       = ${N_COL}"
echo "> FATS_MODE   = ${FAST_MODE}"
echo "> FOUT_FNAME  = ${FOUT_FNAME}"

# exit;

n=0
nmax=15
out_cnt=0

OUTPATH=./tmp/pinned_darks_188K_diff_pinning_time_0504_1000s


if [ -e $OUTPATH ]; then
    echo "$OUTPATH already exist"
else
    mkdir $OUTPATH
fi

# exit


n=1
t=200
while [ $t -le 500 ]
do
    ./power_down
    sleep 10
    ./power_up
    
    FOUT_FNAME=${OUTPATH}/dark_${n}.bin
    FOUT_BIAS=${OUTPATH}/bias_${n}.bin
    echo ${FOUT_FNAME}

    ./refresh ${t};

    FOUT_FNAME=${OUTPATH}/dark_${n}_0.bin
    sleep 1000;
    bin/ccd290_readout -b ${N_BYTES} -r ${N_ROW} -c ${N_COL} -f ${FAST_MODE} -o ${FOUT_FNAME}
    ./readout

    ./refresh ${t};
    FOUT_FNAME=${OUTPATH}/dark_${n}_1.bin
    sleep 1000;
    bin/ccd290_readout -b ${N_BYTES} -r ${N_ROW} -c ${N_COL} -f ${FAST_MODE} -o ${FOUT_FNAME}
    ./readout

    ./refresh ${t};
    FOUT_FNAME=${OUTPATH}/dark_${n}_2.bin
    sleep 1000;
    bin/ccd290_readout -b ${N_BYTES} -r ${N_ROW} -c ${N_COL} -f ${FAST_MODE} -o ${FOUT_FNAME}
    ./readout

    t=$((t + 100))
    n=$((n + 1))
done





echo "*************************************************"
